#ifndef IOC_H
#define IOC_H
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <linux/input.h>
#include <gpiod.h>
#include <mosquitto.h>
#include <cjson/cJSON.h>
#include <syslog.h>
#include "fileop.h"
#include "config.h"

/* LED control */
void led_on(char *led);
void led_off(char *led);
void led_toggle(char *led);
/* End of LED control */

/* fan control */
void fan_on(void);
void fan_off(void);
/* End of fan control */

/* temperature & humidity control */
float temp_read(void);
float hum_read(void);
/* End of temperature & humidity control */

/* voltage read */
float volt_read(void);
/* End of voltage read */

/*buzzer control*/
int buzz(unsigned int value);
void buz_on(void);
void buz_off(void);
/*End of buzzer control*/

/*keys control*/
int key_read(unsigned int key);
/*End of keys control*/

/*cjson control*/
cJSON *cjson_humTem();
cJSON *cjosn_fan();
cJSON *cjson_lamp(int LED_ID, char *led);
void free_cjson(cJSON *obj);
const char *read_cjson_fan(cJSON *obj);
/* End of cjson control */

/*mqtt control*/
void on_message(struct mosquitto *mqtt, void *userdata, const struct mosquitto_message *message);
struct mosquitto *mos_init();
void mos_destroy(struct mosquitto *mqtt);
int mos_send(struct mosquitto *mqtt_mosquitto, int payloadlen, const void *payload);
int mos_loop(struct mosquitto *mqtt);
int mos_subscribe(struct mosquitto *mqtt);
/* End of mqtt control */

#endif /* IOC_H */
